From 8fabd0c6f32878cdae8c97afcd829e1b2fdd09ad Mon Sep 17 00:00:00 2001 From: oliskoli Date: Tue, 28 Nov 2006 12:48:00 +0000 Subject: [PATCH] Check for psitrex comment sign in header names. Allocate always a track header in first read loop. --- gpsbabel/psitrex.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/gpsbabel/psitrex.c b/gpsbabel/psitrex.c index 624433417..d0d6c7187 100755 --- a/gpsbabel/psitrex.c +++ b/gpsbabel/psitrex.c @@ -468,6 +468,8 @@ psit_routehdr_w(FILE *psit_file, const route_head *rte) allWptNameLengths = 0; if (rte->waypoint_list.next) { /* this test doesn't do what I want i.e test if this is a valid route - treat as a placeholder for now */ + char *c; + QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) { testwpt = (waypoint *)elem; if (rte_datapoints == 0) { @@ -488,8 +490,10 @@ psit_routehdr_w(FILE *psit_file, const route_head *rte) else rname = xstrdup(rte->rte_name); - fprintf(psit_file, "Route: %s\n", - rname); + /* check for psitrex comment sign; replace with '$' */ + while ((c = strchr(rname, '#'))) *c = '$'; + + fprintf(psit_file, "Route: %s\n", rname); xfree(rname); } } @@ -532,6 +536,8 @@ psit_track_r(FILE *psit_file, route_head **trk) trk_num = 0; trk_count = 0; + + track_head = NULL; psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), wscomma); @@ -575,7 +581,7 @@ psit_track_r(FILE *psit_file, route_head **trk) psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), whitespace); - if (strcmp(psit_current_token, "1") == 0) { + if ((strcmp(psit_current_token, "1") == 0) || (track_head == NULL)) { track_head = route_head_alloc(); /* Add a number to the track name. With Garmins, the "first" tracklog is usually ACTIVE LOG the second is ACTIVE LOG001 and so on */ @@ -621,6 +627,8 @@ psit_trackhdr_w(FILE *psit_file, const route_head *trk) /* total nodes (waypoints) this track */ trk_datapoints = 0; if (trk->waypoint_list.next) { /* this test doesn't do what I want i.e test if this is a valid track - treat as a placeholder for now */ + char *c; + QUEUE_FOR_EACH(&trk->waypoint_list, elem, tmp) { if (trk_datapoints == 0) { testwpt = (waypoint *)elem; @@ -641,8 +649,10 @@ psit_trackhdr_w(FILE *psit_file, const route_head *trk) else tname = xstrdup(trk->rte_name); - fprintf (psit_file, "Track: %s\n", - tname); + /* check for psitrex comment sign; replace with '$' */ + while ((c = strchr(tname, '#'))) *c = '$'; + + fprintf (psit_file, "Track: %s\n", tname); xfree(tname); } -- 2.30.2